<?php


/**
 * Base class that represents a query for the 'positions' table.
 *
 *
 *
 * @method EmpevalPositionQuery orderById($order = Criteria::ASC) Order by the id column
 * @method EmpevalPositionQuery orderByParentId($order = Criteria::ASC) Order by the parent_id column
 * @method EmpevalPositionQuery orderByBonusGroupId($order = Criteria::ASC) Order by the bonus_group_id column
 * @method EmpevalPositionQuery orderByName($order = Criteria::ASC) Order by the name column
 * @method EmpevalPositionQuery orderByGrade($order = Criteria::ASC) Order by the grade column
 * @method EmpevalPositionQuery orderByActive($order = Criteria::ASC) Order by the active column
 * @method EmpevalPositionQuery orderByLastModified($order = Criteria::ASC) Order by the last_modified column
 * @method EmpevalPositionQuery orderByCreated($order = Criteria::ASC) Order by the created column
 *
 * @method EmpevalPositionQuery groupById() Group by the id column
 * @method EmpevalPositionQuery groupByParentId() Group by the parent_id column
 * @method EmpevalPositionQuery groupByBonusGroupId() Group by the bonus_group_id column
 * @method EmpevalPositionQuery groupByName() Group by the name column
 * @method EmpevalPositionQuery groupByGrade() Group by the grade column
 * @method EmpevalPositionQuery groupByActive() Group by the active column
 * @method EmpevalPositionQuery groupByLastModified() Group by the last_modified column
 * @method EmpevalPositionQuery groupByCreated() Group by the created column
 *
 * @method EmpevalPositionQuery leftJoin($relation) Adds a LEFT JOIN clause to the query
 * @method EmpevalPositionQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query
 * @method EmpevalPositionQuery innerJoin($relation) Adds a INNER JOIN clause to the query
 *
 * @method EmpevalPositionQuery leftJoinBonusGroups($relationAlias = null) Adds a LEFT JOIN clause to the query using the BonusGroups relation
 * @method EmpevalPositionQuery rightJoinBonusGroups($relationAlias = null) Adds a RIGHT JOIN clause to the query using the BonusGroups relation
 * @method EmpevalPositionQuery innerJoinBonusGroups($relationAlias = null) Adds a INNER JOIN clause to the query using the BonusGroups relation
 *
 * @method EmpevalPositionQuery leftJoinPositionRelatedByParentId($relationAlias = null) Adds a LEFT JOIN clause to the query using the PositionRelatedByParentId relation
 * @method EmpevalPositionQuery rightJoinPositionRelatedByParentId($relationAlias = null) Adds a RIGHT JOIN clause to the query using the PositionRelatedByParentId relation
 * @method EmpevalPositionQuery innerJoinPositionRelatedByParentId($relationAlias = null) Adds a INNER JOIN clause to the query using the PositionRelatedByParentId relation
 *
 * @method EmpevalPositionQuery leftJoinPositionRelatedById($relationAlias = null) Adds a LEFT JOIN clause to the query using the PositionRelatedById relation
 * @method EmpevalPositionQuery rightJoinPositionRelatedById($relationAlias = null) Adds a RIGHT JOIN clause to the query using the PositionRelatedById relation
 * @method EmpevalPositionQuery innerJoinPositionRelatedById($relationAlias = null) Adds a INNER JOIN clause to the query using the PositionRelatedById relation
 *
 * @method EmpevalPositionQuery leftJoinUserPositions($relationAlias = null) Adds a LEFT JOIN clause to the query using the UserPositions relation
 * @method EmpevalPositionQuery rightJoinUserPositions($relationAlias = null) Adds a RIGHT JOIN clause to the query using the UserPositions relation
 * @method EmpevalPositionQuery innerJoinUserPositions($relationAlias = null) Adds a INNER JOIN clause to the query using the UserPositions relation
 *
 * @method EmpevalPosition findOne(PropelPDO $con = null) Return the first EmpevalPosition matching the query
 * @method EmpevalPosition findOneOrCreate(PropelPDO $con = null) Return the first EmpevalPosition matching the query, or a new EmpevalPosition object populated from the query conditions when no match is found
 *
 * @method EmpevalPosition findOneById(int $id) Return the first EmpevalPosition filtered by the id column
 * @method EmpevalPosition findOneByParentId(int $parent_id) Return the first EmpevalPosition filtered by the parent_id column
 * @method EmpevalPosition findOneByBonusGroupId(int $bonus_group_id) Return the first EmpevalPosition filtered by the bonus_group_id column
 * @method EmpevalPosition findOneByName(string $name) Return the first EmpevalPosition filtered by the name column
 * @method EmpevalPosition findOneByGrade(int $grade) Return the first EmpevalPosition filtered by the grade column
 * @method EmpevalPosition findOneByActive(boolean $active) Return the first EmpevalPosition filtered by the active column
 * @method EmpevalPosition findOneByLastModified(string $last_modified) Return the first EmpevalPosition filtered by the last_modified column
 * @method EmpevalPosition findOneByCreated(string $created) Return the first EmpevalPosition filtered by the created column
 *
 * @method array findById(int $id) Return EmpevalPosition objects filtered by the id column
 * @method array findByParentId(int $parent_id) Return EmpevalPosition objects filtered by the parent_id column
 * @method array findByBonusGroupId(int $bonus_group_id) Return EmpevalPosition objects filtered by the bonus_group_id column
 * @method array findByName(string $name) Return EmpevalPosition objects filtered by the name column
 * @method array findByGrade(int $grade) Return EmpevalPosition objects filtered by the grade column
 * @method array findByActive(boolean $active) Return EmpevalPosition objects filtered by the active column
 * @method array findByLastModified(string $last_modified) Return EmpevalPosition objects filtered by the last_modified column
 * @method array findByCreated(string $created) Return EmpevalPosition objects filtered by the created column
 *
 * @package    propel.generator.empeval.om
 */
abstract class EmpevalBasePositionQuery extends ModelCriteria
{
    /**
     * Initializes internal state of EmpevalBasePositionQuery object.
     *
     * @param     string $dbName The dabase name
     * @param     string $modelName The phpName of a model, e.g. 'Book'
     * @param     string $modelAlias The alias for the model in this query, e.g. 'b'
     */
    public function __construct($dbName = 'vgp_empeval', $modelName = 'EmpevalPosition', $modelAlias = null)
    {
        parent::__construct($dbName, $modelName, $modelAlias);
    }

    /**
     * Returns a new EmpevalPositionQuery object.
     *
     * @param     string $modelAlias The alias of a model in the query
     * @param     EmpevalPositionQuery|Criteria $criteria Optional Criteria to build the query from
     *
     * @return EmpevalPositionQuery
     */
    public static function create($modelAlias = null, $criteria = null)
    {
        if ($criteria instanceof EmpevalPositionQuery) {
            return $criteria;
        }
        $query = new EmpevalPositionQuery();
        if (null !== $modelAlias) {
            $query->setModelAlias($modelAlias);
        }
        if ($criteria instanceof Criteria) {
            $query->mergeWith($criteria);
        }

        return $query;
    }

    /**
     * Find object by primary key.
     * Propel uses the instance pool to skip the database if the object exists.
     * Go fast if the query is untouched.
     *
     * <code>
     * $obj  = $c->findPk(12, $con);
     * </code>
     *
     * @param mixed $key Primary key to use for the query
     * @param     PropelPDO $con an optional connection object
     *
     * @return   EmpevalPosition|EmpevalPosition[]|mixed the result, formatted by the current formatter
     */
    public function findPk($key, $con = null)
    {
        if ($key === null) {
            return null;
        }
        if ((null !== ($obj = EmpevalPositionPeer::getInstanceFromPool((string) $key))) && !$this->formatter) {
            // the object is alredy in the instance pool
            return $obj;
        }
        if ($con === null) {
            $con = Propel::getConnection(EmpevalPositionPeer::DATABASE_NAME, Propel::CONNECTION_READ);
        }
        $this->basePreSelect($con);
        if ($this->formatter || $this->modelAlias || $this->with || $this->select
         || $this->selectColumns || $this->asColumns || $this->selectModifiers
         || $this->map || $this->having || $this->joins) {
            return $this->findPkComplex($key, $con);
        } else {
            return $this->findPkSimple($key, $con);
        }
    }

    /**
     * Find object by primary key using raw SQL to go fast.
     * Bypass doSelect() and the object formatter by using generated code.
     *
     * @param     mixed $key Primary key to use for the query
     * @param     PropelPDO $con A connection object
     *
     * @return   EmpevalPosition A model object, or null if the key is not found
     * @throws   PropelException
     */
    protected function findPkSimple($key, $con)
    {
        $sql = 'SELECT ID, PARENT_ID, BONUS_GROUP_ID, NAME, GRADE, ACTIVE, LAST_MODIFIED, CREATED FROM positions WHERE ID = :p0';
        try {
            $stmt = $con->prepare($sql);
            $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
            $stmt->execute();
        } catch (Exception $e) {
            Propel::log($e->getMessage(), Propel::LOG_ERR);
            throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e);
        }
        $obj = null;
        if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
            $obj = new EmpevalPosition();
            $obj->hydrate($row);
            EmpevalPositionPeer::addInstanceToPool($obj, (string) $key);
        }
        $stmt->closeCursor();

        return $obj;
    }

    /**
     * Find object by primary key.
     *
     * @param     mixed $key Primary key to use for the query
     * @param     PropelPDO $con A connection object
     *
     * @return EmpevalPosition|EmpevalPosition[]|mixed the result, formatted by the current formatter
     */
    protected function findPkComplex($key, $con)
    {
        // As the query uses a PK condition, no limit(1) is necessary.
        $criteria = $this->isKeepQuery() ? clone $this : $this;
        $stmt = $criteria
            ->filterByPrimaryKey($key)
            ->doSelect($con);

        return $criteria->getFormatter()->init($criteria)->formatOne($stmt);
    }

    /**
     * Find objects by primary key
     * <code>
     * $objs = $c->findPks(array(12, 56, 832), $con);
     * </code>
     * @param     array $keys Primary keys to use for the query
     * @param     PropelPDO $con an optional connection object
     *
     * @return PropelObjectCollection|EmpevalPosition[]|mixed the list of results, formatted by the current formatter
     */
    public function findPks($keys, $con = null)
    {
        if ($con === null) {
            $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ);
        }
        $this->basePreSelect($con);
        $criteria = $this->isKeepQuery() ? clone $this : $this;
        $stmt = $criteria
            ->filterByPrimaryKeys($keys)
            ->doSelect($con);

        return $criteria->getFormatter()->init($criteria)->format($stmt);
    }

    /**
     * Filter the query by primary key
     *
     * @param     mixed $key Primary key to use for the query
     *
     * @return EmpevalPositionQuery The current query, for fluid interface
     */
    public function filterByPrimaryKey($key)
    {

        return $this->addUsingAlias(EmpevalPositionPeer::ID, $key, Criteria::EQUAL);
    }

    /**
     * Filter the query by a list of primary keys
     *
     * @param     array $keys The list of primary key to use for the query
     *
     * @return EmpevalPositionQuery The current query, for fluid interface
     */
    public function filterByPrimaryKeys($keys)
    {

        return $this->addUsingAlias(EmpevalPositionPeer::ID, $keys, Criteria::IN);
    }

    /**
     * Filter the query on the id column
     *
     * Example usage:
     * <code>
     * $query->filterById(1234); // WHERE id = 1234
     * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
     * $query->filterById(array('min' => 12)); // WHERE id > 12
     * </code>
     *
     * @param     mixed $id The value to use as filter.
     *              Use scalar values for equality.
     *              Use array values for in_array() equivalent.
     *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return EmpevalPositionQuery The current query, for fluid interface
     */
    public function filterById($id = null, $comparison = null)
    {
        if (is_array($id) && null === $comparison) {
            $comparison = Criteria::IN;
        }

        return $this->addUsingAlias(EmpevalPositionPeer::ID, $id, $comparison);
    }

    /**
     * Filter the query on the parent_id column
     *
     * Example usage:
     * <code>
     * $query->filterByParentId(1234); // WHERE parent_id = 1234
     * $query->filterByParentId(array(12, 34)); // WHERE parent_id IN (12, 34)
     * $query->filterByParentId(array('min' => 12)); // WHERE parent_id > 12
     * </code>
     *
     * @see       filterByPositionRelatedByParentId()
     *
     * @param     mixed $parentId The value to use as filter.
     *              Use scalar values for equality.
     *              Use array values for in_array() equivalent.
     *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return EmpevalPositionQuery The current query, for fluid interface
     */
    public function filterByParentId($parentId = null, $comparison = null)
    {
        if (is_array($parentId)) {
            $useMinMax = false;
            if (isset($parentId['min'])) {
                $this->addUsingAlias(EmpevalPositionPeer::PARENT_ID, $parentId['min'], Criteria::GREATER_EQUAL);
                $useMinMax = true;
            }
            if (isset($parentId['max'])) {
                $this->addUsingAlias(EmpevalPositionPeer::PARENT_ID, $parentId['max'], Criteria::LESS_EQUAL);
                $useMinMax = true;
            }
            if ($useMinMax) {
                return $this;
            }
            if (null === $comparison) {
                $comparison = Criteria::IN;
            }
        }

        return $this->addUsingAlias(EmpevalPositionPeer::PARENT_ID, $parentId, $comparison);
    }

    /**
     * Filter the query on the bonus_group_id column
     *
     * Example usage:
     * <code>
     * $query->filterByBonusGroupId(1234); // WHERE bonus_group_id = 1234
     * $query->filterByBonusGroupId(array(12, 34)); // WHERE bonus_group_id IN (12, 34)
     * $query->filterByBonusGroupId(array('min' => 12)); // WHERE bonus_group_id > 12
     * </code>
     *
     * @see       filterByBonusGroups()
     *
     * @param     mixed $bonusGroupId The value to use as filter.
     *              Use scalar values for equality.
     *              Use array values for in_array() equivalent.
     *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return EmpevalPositionQuery The current query, for fluid interface
     */
    public function filterByBonusGroupId($bonusGroupId = null, $comparison = null)
    {
        if (is_array($bonusGroupId)) {
            $useMinMax = false;
            if (isset($bonusGroupId['min'])) {
                $this->addUsingAlias(EmpevalPositionPeer::BONUS_GROUP_ID, $bonusGroupId['min'], Criteria::GREATER_EQUAL);
                $useMinMax = true;
            }
            if (isset($bonusGroupId['max'])) {
                $this->addUsingAlias(EmpevalPositionPeer::BONUS_GROUP_ID, $bonusGroupId['max'], Criteria::LESS_EQUAL);
                $useMinMax = true;
            }
            if ($useMinMax) {
                return $this;
            }
            if (null === $comparison) {
                $comparison = Criteria::IN;
            }
        }

        return $this->addUsingAlias(EmpevalPositionPeer::BONUS_GROUP_ID, $bonusGroupId, $comparison);
    }

    /**
     * Filter the query on the name column
     *
     * Example usage:
     * <code>
     * $query->filterByName('fooValue');   // WHERE name = 'fooValue'
     * $query->filterByName('%fooValue%'); // WHERE name LIKE '%fooValue%'
     * </code>
     *
     * @param     string $name The value to use as filter.
     *              Accepts wildcards (* and % trigger a LIKE)
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return EmpevalPositionQuery The current query, for fluid interface
     */
    public function filterByName($name = null, $comparison = null)
    {
        if (null === $comparison) {
            if (is_array($name)) {
                $comparison = Criteria::IN;
            } elseif (preg_match('/[\%\*]/', $name)) {
                $name = str_replace('*', '%', $name);
                $comparison = Criteria::LIKE;
            }
        }

        return $this->addUsingAlias(EmpevalPositionPeer::NAME, $name, $comparison);
    }

    /**
     * Filter the query on the grade column
     *
     * Example usage:
     * <code>
     * $query->filterByGrade(1234); // WHERE grade = 1234
     * $query->filterByGrade(array(12, 34)); // WHERE grade IN (12, 34)
     * $query->filterByGrade(array('min' => 12)); // WHERE grade > 12
     * </code>
     *
     * @param     mixed $grade The value to use as filter.
     *              Use scalar values for equality.
     *              Use array values for in_array() equivalent.
     *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return EmpevalPositionQuery The current query, for fluid interface
     */
    public function filterByGrade($grade = null, $comparison = null)
    {
        if (is_array($grade)) {
            $useMinMax = false;
            if (isset($grade['min'])) {
                $this->addUsingAlias(EmpevalPositionPeer::GRADE, $grade['min'], Criteria::GREATER_EQUAL);
                $useMinMax = true;
            }
            if (isset($grade['max'])) {
                $this->addUsingAlias(EmpevalPositionPeer::GRADE, $grade['max'], Criteria::LESS_EQUAL);
                $useMinMax = true;
            }
            if ($useMinMax) {
                return $this;
            }
            if (null === $comparison) {
                $comparison = Criteria::IN;
            }
        }

        return $this->addUsingAlias(EmpevalPositionPeer::GRADE, $grade, $comparison);
    }

    /**
     * Filter the query on the active column
     *
     * Example usage:
     * <code>
     * $query->filterByActive(true); // WHERE active = true
     * $query->filterByActive('yes'); // WHERE active = true
     * </code>
     *
     * @param     boolean|string $active The value to use as filter.
     *              Non-boolean arguments are converted using the following rules:
     *                * 1, '1', 'true',  'on',  and 'yes' are converted to boolean true
     *                * 0, '0', 'false', 'off', and 'no'  are converted to boolean false
     *              Check on string values is case insensitive (so 'FaLsE' is seen as 'false').
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return EmpevalPositionQuery The current query, for fluid interface
     */
    public function filterByActive($active = null, $comparison = null)
    {
        if (is_string($active)) {
            $active = in_array(strtolower($active), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true;
        }

        return $this->addUsingAlias(EmpevalPositionPeer::ACTIVE, $active, $comparison);
    }

    /**
     * Filter the query on the last_modified column
     *
     * Example usage:
     * <code>
     * $query->filterByLastModified('2011-03-14'); // WHERE last_modified = '2011-03-14'
     * $query->filterByLastModified('now'); // WHERE last_modified = '2011-03-14'
     * $query->filterByLastModified(array('max' => 'yesterday')); // WHERE last_modified > '2011-03-13'
     * </code>
     *
     * @param     mixed $lastModified The value to use as filter.
     *              Values can be integers (unix timestamps), DateTime objects, or strings.
     *              Empty strings are treated as NULL.
     *              Use scalar values for equality.
     *              Use array values for in_array() equivalent.
     *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return EmpevalPositionQuery The current query, for fluid interface
     */
    public function filterByLastModified($lastModified = null, $comparison = null)
    {
        if (is_array($lastModified)) {
            $useMinMax = false;
            if (isset($lastModified['min'])) {
                $this->addUsingAlias(EmpevalPositionPeer::LAST_MODIFIED, $lastModified['min'], Criteria::GREATER_EQUAL);
                $useMinMax = true;
            }
            if (isset($lastModified['max'])) {
                $this->addUsingAlias(EmpevalPositionPeer::LAST_MODIFIED, $lastModified['max'], Criteria::LESS_EQUAL);
                $useMinMax = true;
            }
            if ($useMinMax) {
                return $this;
            }
            if (null === $comparison) {
                $comparison = Criteria::IN;
            }
        }

        return $this->addUsingAlias(EmpevalPositionPeer::LAST_MODIFIED, $lastModified, $comparison);
    }

    /**
     * Filter the query on the created column
     *
     * Example usage:
     * <code>
     * $query->filterByCreated('2011-03-14'); // WHERE created = '2011-03-14'
     * $query->filterByCreated('now'); // WHERE created = '2011-03-14'
     * $query->filterByCreated(array('max' => 'yesterday')); // WHERE created > '2011-03-13'
     * </code>
     *
     * @param     mixed $created The value to use as filter.
     *              Values can be integers (unix timestamps), DateTime objects, or strings.
     *              Empty strings are treated as NULL.
     *              Use scalar values for equality.
     *              Use array values for in_array() equivalent.
     *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return EmpevalPositionQuery The current query, for fluid interface
     */
    public function filterByCreated($created = null, $comparison = null)
    {
        if (is_array($created)) {
            $useMinMax = false;
            if (isset($created['min'])) {
                $this->addUsingAlias(EmpevalPositionPeer::CREATED, $created['min'], Criteria::GREATER_EQUAL);
                $useMinMax = true;
            }
            if (isset($created['max'])) {
                $this->addUsingAlias(EmpevalPositionPeer::CREATED, $created['max'], Criteria::LESS_EQUAL);
                $useMinMax = true;
            }
            if ($useMinMax) {
                return $this;
            }
            if (null === $comparison) {
                $comparison = Criteria::IN;
            }
        }

        return $this->addUsingAlias(EmpevalPositionPeer::CREATED, $created, $comparison);
    }

    /**
     * Filter the query by a related EmpevalBonusGroups object
     *
     * @param   EmpevalBonusGroups|PropelObjectCollection $bonusGroups The related object(s) to use as filter
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return   EmpevalPositionQuery The current query, for fluid interface
     * @throws   PropelException - if the provided filter is invalid.
     */
    public function filterByBonusGroups($bonusGroups, $comparison = null)
    {
        if ($bonusGroups instanceof EmpevalBonusGroups) {
            return $this
                ->addUsingAlias(EmpevalPositionPeer::BONUS_GROUP_ID, $bonusGroups->getId(), $comparison);
        } elseif ($bonusGroups instanceof PropelObjectCollection) {
            if (null === $comparison) {
                $comparison = Criteria::IN;
            }

            return $this
                ->addUsingAlias(EmpevalPositionPeer::BONUS_GROUP_ID, $bonusGroups->toKeyValue('PrimaryKey', 'Id'), $comparison);
        } else {
            throw new PropelException('filterByBonusGroups() only accepts arguments of type EmpevalBonusGroups or PropelCollection');
        }
    }

    /**
     * Adds a JOIN clause to the query using the BonusGroups relation
     *
     * @param     string $relationAlias optional alias for the relation
     * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
     *
     * @return EmpevalPositionQuery The current query, for fluid interface
     */
    public function joinBonusGroups($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
    {
        $tableMap = $this->getTableMap();
        $relationMap = $tableMap->getRelation('BonusGroups');

        // create a ModelJoin object for this join
        $join = new ModelJoin();
        $join->setJoinType($joinType);
        $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
        if ($previousJoin = $this->getPreviousJoin()) {
            $join->setPreviousJoin($previousJoin);
        }

        // add the ModelJoin to the current object
        if ($relationAlias) {
            $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
            $this->addJoinObject($join, $relationAlias);
        } else {
            $this->addJoinObject($join, 'BonusGroups');
        }

        return $this;
    }

    /**
     * Use the BonusGroups relation BonusGroups object
     *
     * @see       useQuery()
     *
     * @param     string $relationAlias optional alias for the relation,
     *                                   to be used as main alias in the secondary query
     * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
     *
     * @return   EmpevalBonusGroupsQuery A secondary query class using the current class as primary query
     */
    public function useBonusGroupsQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
    {
        return $this
            ->joinBonusGroups($relationAlias, $joinType)
            ->useQuery($relationAlias ? $relationAlias : 'BonusGroups', 'EmpevalBonusGroupsQuery');
    }

    /**
     * Filter the query by a related EmpevalPosition object
     *
     * @param   EmpevalPosition|PropelObjectCollection $position The related object(s) to use as filter
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return   EmpevalPositionQuery The current query, for fluid interface
     * @throws   PropelException - if the provided filter is invalid.
     */
    public function filterByPositionRelatedByParentId($position, $comparison = null)
    {
        if ($position instanceof EmpevalPosition) {
            return $this
                ->addUsingAlias(EmpevalPositionPeer::PARENT_ID, $position->getId(), $comparison);
        } elseif ($position instanceof PropelObjectCollection) {
            if (null === $comparison) {
                $comparison = Criteria::IN;
            }

            return $this
                ->addUsingAlias(EmpevalPositionPeer::PARENT_ID, $position->toKeyValue('PrimaryKey', 'Id'), $comparison);
        } else {
            throw new PropelException('filterByPositionRelatedByParentId() only accepts arguments of type EmpevalPosition or PropelCollection');
        }
    }

    /**
     * Adds a JOIN clause to the query using the PositionRelatedByParentId relation
     *
     * @param     string $relationAlias optional alias for the relation
     * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
     *
     * @return EmpevalPositionQuery The current query, for fluid interface
     */
    public function joinPositionRelatedByParentId($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
    {
        $tableMap = $this->getTableMap();
        $relationMap = $tableMap->getRelation('PositionRelatedByParentId');

        // create a ModelJoin object for this join
        $join = new ModelJoin();
        $join->setJoinType($joinType);
        $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
        if ($previousJoin = $this->getPreviousJoin()) {
            $join->setPreviousJoin($previousJoin);
        }

        // add the ModelJoin to the current object
        if ($relationAlias) {
            $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
            $this->addJoinObject($join, $relationAlias);
        } else {
            $this->addJoinObject($join, 'PositionRelatedByParentId');
        }

        return $this;
    }

    /**
     * Use the PositionRelatedByParentId relation Position object
     *
     * @see       useQuery()
     *
     * @param     string $relationAlias optional alias for the relation,
     *                                   to be used as main alias in the secondary query
     * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
     *
     * @return   EmpevalPositionQuery A secondary query class using the current class as primary query
     */
    public function usePositionRelatedByParentIdQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
    {
        return $this
            ->joinPositionRelatedByParentId($relationAlias, $joinType)
            ->useQuery($relationAlias ? $relationAlias : 'PositionRelatedByParentId', 'EmpevalPositionQuery');
    }

    /**
     * Filter the query by a related EmpevalPosition object
     *
     * @param   EmpevalPosition|PropelObjectCollection $position  the related object to use as filter
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return   EmpevalPositionQuery The current query, for fluid interface
     * @throws   PropelException - if the provided filter is invalid.
     */
    public function filterByPositionRelatedById($position, $comparison = null)
    {
        if ($position instanceof EmpevalPosition) {
            return $this
                ->addUsingAlias(EmpevalPositionPeer::ID, $position->getParentId(), $comparison);
        } elseif ($position instanceof PropelObjectCollection) {
            return $this
                ->usePositionRelatedByIdQuery()
                ->filterByPrimaryKeys($position->getPrimaryKeys())
                ->endUse();
        } else {
            throw new PropelException('filterByPositionRelatedById() only accepts arguments of type EmpevalPosition or PropelCollection');
        }
    }

    /**
     * Adds a JOIN clause to the query using the PositionRelatedById relation
     *
     * @param     string $relationAlias optional alias for the relation
     * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
     *
     * @return EmpevalPositionQuery The current query, for fluid interface
     */
    public function joinPositionRelatedById($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
    {
        $tableMap = $this->getTableMap();
        $relationMap = $tableMap->getRelation('PositionRelatedById');

        // create a ModelJoin object for this join
        $join = new ModelJoin();
        $join->setJoinType($joinType);
        $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
        if ($previousJoin = $this->getPreviousJoin()) {
            $join->setPreviousJoin($previousJoin);
        }

        // add the ModelJoin to the current object
        if ($relationAlias) {
            $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
            $this->addJoinObject($join, $relationAlias);
        } else {
            $this->addJoinObject($join, 'PositionRelatedById');
        }

        return $this;
    }

    /**
     * Use the PositionRelatedById relation Position object
     *
     * @see       useQuery()
     *
     * @param     string $relationAlias optional alias for the relation,
     *                                   to be used as main alias in the secondary query
     * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
     *
     * @return   EmpevalPositionQuery A secondary query class using the current class as primary query
     */
    public function usePositionRelatedByIdQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
    {
        return $this
            ->joinPositionRelatedById($relationAlias, $joinType)
            ->useQuery($relationAlias ? $relationAlias : 'PositionRelatedById', 'EmpevalPositionQuery');
    }

    /**
     * Filter the query by a related EmpevalUserPositions object
     *
     * @param   EmpevalUserPositions|PropelObjectCollection $userPositions  the related object to use as filter
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return   EmpevalPositionQuery The current query, for fluid interface
     * @throws   PropelException - if the provided filter is invalid.
     */
    public function filterByUserPositions($userPositions, $comparison = null)
    {
        if ($userPositions instanceof EmpevalUserPositions) {
            return $this
                ->addUsingAlias(EmpevalPositionPeer::ID, $userPositions->getPositionId(), $comparison);
        } elseif ($userPositions instanceof PropelObjectCollection) {
            return $this
                ->useUserPositionsQuery()
                ->filterByPrimaryKeys($userPositions->getPrimaryKeys())
                ->endUse();
        } else {
            throw new PropelException('filterByUserPositions() only accepts arguments of type EmpevalUserPositions or PropelCollection');
        }
    }

    /**
     * Adds a JOIN clause to the query using the UserPositions relation
     *
     * @param     string $relationAlias optional alias for the relation
     * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
     *
     * @return EmpevalPositionQuery The current query, for fluid interface
     */
    public function joinUserPositions($relationAlias = null, $joinType = Criteria::INNER_JOIN)
    {
        $tableMap = $this->getTableMap();
        $relationMap = $tableMap->getRelation('UserPositions');

        // create a ModelJoin object for this join
        $join = new ModelJoin();
        $join->setJoinType($joinType);
        $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
        if ($previousJoin = $this->getPreviousJoin()) {
            $join->setPreviousJoin($previousJoin);
        }

        // add the ModelJoin to the current object
        if ($relationAlias) {
            $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
            $this->addJoinObject($join, $relationAlias);
        } else {
            $this->addJoinObject($join, 'UserPositions');
        }

        return $this;
    }

    /**
     * Use the UserPositions relation UserPositions object
     *
     * @see       useQuery()
     *
     * @param     string $relationAlias optional alias for the relation,
     *                                   to be used as main alias in the secondary query
     * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
     *
     * @return   EmpevalUserPositionsQuery A secondary query class using the current class as primary query
     */
    public function useUserPositionsQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
    {
        return $this
            ->joinUserPositions($relationAlias, $joinType)
            ->useQuery($relationAlias ? $relationAlias : 'UserPositions', 'EmpevalUserPositionsQuery');
    }

    /**
     * Exclude object from result
     *
     * @param   EmpevalPosition $position Object to remove from the list of results
     *
     * @return EmpevalPositionQuery The current query, for fluid interface
     */
    public function prune($position = null)
    {
        if ($position) {
            $this->addUsingAlias(EmpevalPositionPeer::ID, $position->getId(), Criteria::NOT_EQUAL);
        }

        return $this;
    }

}
